<template>
  <div id="olMap" class="olMap">
    <div class="mapMenuBox">
      <ocn-map-menu-bar></ocn-map-menu-bar>
    </div>
  </div>
</template>
<script>
import MapBusiness from "./OLClasses/mapBusiness_class";
import { selfMap_config } from "./OLClasses/baseMap_config";

import { mapGetters, mapMutations } from "vuex";

export default {
  name: "olMap",
  data() {
    return {};
  },
  computed: {
    ...mapGetters("olMap", ["getBaseMap", "getMapBusiness"]),
  },
  created() {},
  mounted() {
    this.createBaseMap();
  },
  methods: {
    ...mapMutations("olMap", ["setBaseMap", "setMapBusiness"]),
    /**
     * @author QL
     * @functionName createBaseMap
     * @param { - }
     * @date 2021-12-28 16:52:41
     * @version V..
     * @description 创建底图的视图区域
     */
    createBaseMap() {
      // 传入底图实例，实例化对应底图实例业务操作的类对象
      let mapBusiness = new MapBusiness(selfMap_config, "olMap");
      // 初始化事件监听绑定自定义事件列表
      mapBusiness.initEvents();

      this.setBaseMap({
        typeName: "page",
        valueVal: mapBusiness.baseMap,
        fn: (obj) => {
          this.$utils.setConsole("set操作同步回调---：", obj);
          this.$utils.setConsole(
            "set操作同步回调---：",
            this.getBaseMap("page")
          );
        },
      });

      this.setMapBusiness({
        typeName: "page",
        valueVal: mapBusiness,
        fn: (obj) => {
          this.$utils.setConsole("set操作同步回调---：", obj);
          this.$utils.setConsole(
            "set操作同步回调---：",
            this.getMapBusiness("page")
          );
        },
      });

      window.addEventListener("resize", () => {
        mapBusiness.baseMap.updateSize();
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.olMap {
  height: 100%;
  margin: 2px;
  border-radius: 6px;
  /* stretch 属性标识按照对称轴垂直方向沾满容器 前提是容器没有设置对称轴垂直方向的距离属性 width/height*/
  align-self: stretch;

  display: flex;
  flex-direction: column;
}

.mapMenuBox {
  width: 100%;
  background: rgb(152, 161, 245);
  z-index: 10;
  flex: 10;
}

.ol-viewport {
  display: flex;
  flex: 80;
}
</style>